package com.ch10;

import com.ch10.config.AppConfig;
import com.ch10.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @ClassName Main
 * @Description TODO
 * @Author Kx
 * @Date 2025/4/30 11:19
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {
        // 使用容器初始化配置类
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        // 从容器中获取Bean对象
        UserService bean1 = context.getBean(UserService.class);
        System.out.println(bean1);
        bean1.add();

        UserService bean2 = context.getBean(UserService.class);
        System.out.println(bean2);
        bean2.add();
    }
}
